<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>模块型号名称：</p>
                                <input type="text" name="modelName"/>
                            </li>
                            <li>
                                <p>模块型号编号：</p>
                                <input type="text" name="modelId"/>
                            </li>
                            <li>
                                <p>所在电池箱外键：</p>
                                <input type="text" name="boxId"/>
                            </li>
                            <li>
                                <p>所在电池箱编码：</p>
                                <input type="text" name="boxCode"/>
                            </li>
                            <li>
                                <p>电池模块性能参数：</p>
                                <input type="text" name="bmPower"/>
                            </li>
                            <li>
                                <p>单体串并联方式：</p>
                                <select name="singleType" th:with="type=${@dict.getType('')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>单体电池个数：</p>
                                <input type="text" name="singleCount"/>
                            </li>
                            <li>
                                <p>生产厂商：</p>
                                <input type="text" name="modelCompany"/>
                            </li>
                            <li>
                                <p>模块编号：</p>
                                <input type="text" name="modularCode"/>
                            </li>
                            <li>
                                <p>模块规格代码：</p>
                                <input type="text" name="modularSpecifications"/>
                            </li>
                            <li>
                                <p>所含单体电池编号：</p>
                                <input type="text" name="singleId"/>
                            </li>
                            <li>
                                <p>实际容量：</p>
                                <input type="text" name="modelVolume"/>
                            </li>
                            <li>
                                <p>实际电压：</p>
                                <input type="text" name="modelVoltage"/>
                            </li>
                            <li>
                                <p>实际质量：</p>
                                <input type="text" name="modelQuality"/>
                            </li>
                            <li>
                                <p>模块流向：</p>
                                <input type="text" name="modelDirection"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:cellmodel:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:cellmodel:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:cellmodel:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:cellmodel:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>

     <a href="#myModal" role="button" class="btn" data-toggle="modal">查看演示案例</a>

     <!-- Modal -->
     <div  class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
         <div class="modal-dialog" role="document">
             <div class="modal-content" style="width: 700px;height:350px">
                 <div class="modal-header">
                     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                     <h4 class="modal-title" id="myModalLabel">电池模块性能参数</h4>
                 </div>
                 <div class="modal-body">
                     <div class="col-md-12">
                         <div class="form-group">
                             <label class="col-sm-3 control-label">模块编号：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="modularCode" class="form-control" readonly>
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">模块规格代码：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="modularSpecifications" class="form-control" readonly>
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">单体电池编号：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="singleId" class="form-control" readonly>
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">实际容量：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="modelVolume" class="form-control" readonly>
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">实际电压：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="modelVoltage" class="form-control" readonly>
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">实际质量：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="modelQuality" class="form-control" readonly>
                             </div>
                         </div><br>
                         <div class="form-group">
                             <label class="col-sm-3 control-label">模块流向：</label>
                             <div class="col-sm-9">
                                 <input style="border: none" type="text" name="modelDirection" class="form-control" readonly>
                             </div>
                         </div>
                     </div>
                 </div>
                 <div class="modal-footer">
                     <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                 </div>
             </div>
         </div>
     </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript" type="text/javascript">
        var editFlag = [[${@permission.hasPermi('system:cellmodel:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:cellmodel:remove')}]];
        var prefix = ctx + "system/cellmodel";

        function detail(id){
            $.ajax({
                url:prefix+"/zhanshi",
                type:"get",
                data:{'bmId':id},
                success:function (data){
                    console.log(data);
                    $("[name='modularCode']").val(data.modularCode);
                    $("[name='modularSpecifications']").val(data.modularSpecifications);
                    $("[name='singleId']").val(data.singleId);
                    $("[name='modelVolume']").val(data.modelVolume);
                    $("[name='modelVoltage']").val(data.modelVoltage);
                    $("[name='modelQuality']").val(data.modelQuality);
                    $("[name='modelDirection']").val(data.modelDirection);
                },
                datatype:"json"
            })
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "【请填写功能名称】",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'bmId', 
                    title : '编号',
                    visible: false
                },
                {
                    field : 'modelName', 
                    title : '模块型号名称'
                },
                {
                    field : 'modelId', 
                    title : '模块型号编号'
                },
                {
                    field : 'boxId', 
                    title : '所在电池箱外键'
                },
                {
                    field : 'boxCode', 
                    title : '所在电池箱编码'
                },
                    {
                        title : '电池模块性能参数',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a data-toggle="modal" data-target="#myModal" onclick="detail(\'' + row.bmId + '\')">查看详细信息</a>');
                            return actions.join('');
                        }

                    },
                {
                    field : 'singleType', 
                    title : '单体串并联方式'
                },
                {
                    field : 'singleCount', 
                    title : '单体电池个数'
                },
                {
                    field : 'modelCompany', 
                    title : '生产厂商'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.bmId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.bmId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>